﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Services.Client;
using LCA.Community.DAL.Model;

namespace LCA.Community.DAL.Interfaces
{
    /// <summary>
    /// The interface for the data service context that access to a specific table.
    /// </summary>
    /// <typeparam name="T">The class that represents the table data.</typeparam>
    public interface IDataServiceContext<T> where T : BasicDataModel
    {
        /// <summary>
        /// Adds the object.
        /// </summary>
        /// <param name="entitySetName">Name of the entity set.</param>
        /// <param name="entity">The entity.</param>
        void AddObject(string entitySetName, object entity);
        /// <summary>
        /// Deletes the object.
        /// </summary>
        /// <param name="entity">The entity.</param>
        void DeleteObject(object entity);
        /// <summary>
        /// Tries to attach an entity to the context.
        /// </summary>
        /// <param name="entity">The entity.</param>
        void TryAttachTo(T entity);
        /// <summary>
        /// Updates the object.
        /// </summary>
        /// <param name="entity">The entity.</param>
        void UpdateObject(object entity);
        /// <summary>
        /// Saves the changes.
        /// </summary>
        DataServiceResponse SaveChanges();

        /// <summary>
        /// Gets or sets the table entities.
        /// </summary>
        /// <value>The table entities.</value>
        IQueryable<T> TableEntities { get; }
        /// <summary>
        /// Gets the name of the table.
        /// </summary>
        /// <value>The name of the table.</value>
        string TableName { get; }
    }
}
